/**
 * 将数组每spliter个分为一组
 */


 let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
 function splitBySpliter(arr, spliter){
    if(!Array.isArray(arr)) return 

    let newArr = []
    for(let i=0; i< arr.length;) {
       newArr.push(arr.slice(i, i+= spliter))
    }
    return newArr
 }

 const res = splitBySpliter(arr, 5)
//  二维数组
 console.log(res);
//  展开, 一维数组
 console.log(...res);